package com.dem.javatestwebsocket.vo;

import lombok.Data;

import java.util.List;
/**
 * 项目定义的状态码, 这里定义 0 表示成功,其他表示其他的错误代码;
 */

@Data
public class RestResultVo<T> {


    private int status;
    private String message;
    private T data;

    public static <T> RestResultVo<T> success() {
        RestResultVo<T> resultVo = new RestResultVo<>();
        resultVo.setStatus(0);
        return resultVo;
    }
//创建一个状态码为零的rst属性，把传入的数据给data，操作成功并返回数据
    public static <T> RestResultVo<T> ok(T data) {
        RestResultVo<T> resultVo = new RestResultVo<>();
        resultVo.setStatus(0);
        resultVo.setData(data);
        return resultVo;
    }

    public static <T> RestResultVo<T> failed(String msg) {
        RestResultVo<T> resultVo = new RestResultVo<>();
        resultVo.setStatus(-1);
        resultVo.setMessage(msg);
        return resultVo;
    }

    public static <T> RestResultVo<T> failed() {
        RestResultVo<T> resultVo = new RestResultVo<>();
        resultVo.setStatus(-1);
        return resultVo;
    }
}
